<template>
  <div class="task-container" v-loading.fullscreen.lock="loadingPage" >
    <form class="base-form" @submit.prevent v-if="init" novalidate>

      <div class="page-title">
        <div class="title">
          
          <!-- start 工单按钮组 -->

          <button type="button" class="btn-text btn-back" :disabled="disabled" @click="goBack" v-if="isShowBackButton">
            返回
          </button>

          <!-- start 新建按钮组 -->
          <template v-if="isShowTaskButtonGroup">

            <button type="button" class="btn btn-primary" :disabled="disabled" @click="submit(false)" v-if="isShowSaveButton" v-track="$track.formatParams('SAVE')">
              保存
            </button>

            <button type="button" class="btn-text btn-back" :disabled="disabled" @click="submit(false)" v-if="isShowOnlySaveButton" v-track="$track.formatParams('SAVE_ONLY')">
              只保存
            </button>

            <span class="text" v-if="isShowSaveAndAllotButton">|</span>
            
            <button type="button" class="btn btn-primary" :disabled="disabled" @click="submit(true)" v-if="isShowSaveAndAllotButton" v-track="$track.formatParams('SAVE_AND_ALLOT')">
              保存并派单
            </button>

          </template>
          <!-- end 新建按钮组 -->

          <!-- start 新建计划任务 -->
          <button type="button" class="btn btn-primary" :disabled="disabled" v-if="isFromPlan" @click="planTaskCreateDialogOpen" v-track="$track.formatParams('CREATE_PLAN_TASK')">
            保存为计划任务
          </button>
          <!-- end 新建计划任务 -->

          <!-- start 编辑计划任务 -->
          <button type="button" class="btn btn-primary" :disabled="disabled" @click="planTaskEditDialogOpen" v-if="isPlanTaskEdit && isCanTaskPlanEdit" v-track="$track.formatParams('EDIT_PLAN_TASK')">
            保存计划任务
          </button>
          <!-- end 编辑计划任务 -->

        </div>
        <!-- end 工单按钮组 -->

      </div>

      <task-edit-form :auth="auth" :task="task" :fields.sync="fields" :state="state" :types="types" :url-params="urlParams" :value.sync="form" ref="form" @updatetemplateId="updateTaskTemplateId"></task-edit-form>
    </form>

    <!-- start 新建/编辑 计划任务弹窗 -->
    <plan-task-edit-form :origin-form="form" :task-config="taskConfig" @loading="togglePending" @submit="submitWithPlanTask" ref="planTaskEditForm">

    </plan-task-edit-form>
    <!-- end 新建/编辑 计划任务弹窗 -->

  </div>
</template>

<script>
import TaskEditView from './TaskEditView';
export default TaskEditView;
</script>

<style lang="scss">
  @import './TaskEditView.scss';
</style>
